#ifndef _SURBAIS_FILE_KEYS_H_
#define _SURBAIS_FILE_KEYS_H_

// This file implements the algorithms to encrypt/decrypt
// AES keys used in our encryption storage
//
// STORAGE_KEY:
//    the plain AES key used to encryt file data
//
// SHARE_KEY:
//    using (SHA512[0:16] || SHA512[48:64]) as AES key to encryt
//    STORAGE_KEY, so only the ones who get the plain data of the file
//    can get SHA512 and decrypt SHARE_KEY
//
// PERSONAL_KEY:
//    using user's ECC private key to encrypt STORAGE_KEY, so only the
//    user can decrypt PERSONAL_KEY
//

#include "surbasic/EciesHelper.h"

namespace SDBasic {

std::string GeneratePersonalKey(ecc::EciesHelper* ecc,
                                const std::string& storage_key);

std::string EncryptStorageKeyToShareKey(const std::string& sha512,
                                        const std::string& storage_key);

bool DecryptStorageKeyFromShareKey(const std::string& share_key,
                                   const std::string& sha512,
                                   std::string* storage_key,
                                   std::string* errmsg);
}

#endif  // _SURBAIS_FILE_KEYS_H_
